import React, { Component } from "react";
import PropTypes from 'prop-types';

export default class Father extends Component {
    render() {
        return (
            <div>

                <Child list={[1,2,3]} fn={()=> <span>我是函数返回的一个dom</span>}></Child>
            </div>

        )
    }
}

class Child extends Component {
    render() {
        return (
            <div>
                <div>子组件接受到的值：{this.props.data}</div>
                <ul>
                    {
                        this.props.list.map(item => <li key={item}>{item}</li>)
                    }
                </ul>
                <h1>{this.props.fn()}</h1>
            </div>
        )
    }
}

Child.propTypes = {
    data: PropTypes.string,
    list: PropTypes.array.isRequired,
    fn: PropTypes.func.isRequired
}

Child.defaultProps = {
    data: "我是默认值",
    list: [1, 2, 3, 4, 5]
}